<template>
  <div>
    <!-- 搜索栏 -->
    <div>
      <el-input
        placeholder="请输入职称名称"
        v-model="input"
        clearable
        style="width: 300px; margin: 0 10px 20px 0"
      >
      </el-input>
      <el-button type="primary" size="medium">搜索</el-button>
    </div>
    <!-- 表格 -->
    <el-table
      ref="multipleTable"
      :data="tableData"
      tooltip-effect="dark"
      style="width: 100%; text-align: center"
      @selection-change="handleSelectionChange"
      :cell-style="{ 'text-align': 'center' }"
      :header-cell-style="{ 'text-align': 'center' }"
    >
      <el-table-column type="selection" width="55"> </el-table-column>

      <el-table-column prop="name" label="职称名称"></el-table-column>

      <el-table-column label="挂号费用（元）">
        <template slot-scope="scope">{{ scope.row.date }}</template>
      </el-table-column>

      <el-table-column label="职称描述">
        <template slot-scope="scope">{{ scope.row.address }}</template>
      </el-table-column>

      <el-table-column label="添加时间">
        <template slot-scope="scope">{{ scope.row.date }}</template>
      </el-table-column>

      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button size="mini" @click="handleEdit(scope.$index, scope.row)"
            >编辑</el-button
          >
          <el-button
            size="mini"
            type="danger"
            @click="handleDelete(scope.$index, scope.row)"
            >删除</el-button
          >
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
export default {
  data() {
    return {
      tableData: [
        {
          name: "主治医师",
          address: "普通用户,不可删除",
          date: "2021-11-11",
        },
        {
          name: "副主任医师",
          address: "普通用户,不可删除",
          date: "2021-11-11",
        },
        {
          name: "主任医师",
          address: "有最高权限的角色,不可删除",
          date: "2021-11-11",
        },
        {
          name: "主治医师",
          address: "普通用户,不可删除",
          date: "2021-11-11",
        },
        {
          name: "副主任医师",
          address: "普通用户,不可删除",
          date: "2021-11-11",
        },
        {
          name: "主任医师",
          address: "有最高权限的角色,不可删除",
          date: "2021-11-11",
        },
        {
          name: "主治医师",
          address: "普通用户,不可删除",
          date: "2021-11-11",
        },
        {
          name: "副主任医师",
          address: "普通用户,不可删除",
          date: "2021-11-11",
        },
        {
          name: "主任医师",
          address: "有最高权限的角色,不可删除",
          date: "2021-11-11",
        },
      ],
      multipleSelection: [],
      input: "",
      // 分页
      currentPage: 1,
    };
  },
  methods: {
    toggleSelection(rows) {
      if (rows) {
        rows.forEach((row) => {
          this.$refs.multipleTable.toggleRowSelection(row);
        });
      } else {
        this.$refs.multipleTable.clearSelection();
      }
    },
    handleSelectionChange(val) {
      this.multipleSelection = val;
    },
    handleEdit(index, row) {
      console.log(index, row);
    },
    handleDelete(index, row) {
      console.log(index, row);
    },
    // 分页
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
    },
  },
};
</script>

<style lang="scss" scoped>
@import "./scss/index.scss";
</style>